/* eslint-disable */
import IndexService from '@/api/index'
import PaginationTable from '@/components/paginationTable/paginationTable.vue'
export default {
      components: {PaginationTable},
      data() {
        return {
          list: [],
          columns: [
            {
              prop: 'title',
              label: '品牌名称',
              sortable: true
            },
            {
              prop: 'title',
              label: '有无商标',
            },
            {
              prop: 'title',
              label: '商标注册号',
            },
            {
                prop: 'title',
              label: '图片/logo',
                render: (h, params) => {
                  let url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550569527394&di=499bf315a80c859a4acf70e24e766221&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D843574905%2C2376842750%26fm%3D214%26gp%3D0.jpg";
                  return (
                    <img src={url} onClick={() => { this.check(params) }} style="width:45px;height:45px"/>
                  )
                }
            },
            {
              prop: 'title',
              label: '品牌描述',
            },
            {
              prop: 'state',
              label: '品牌状态',
              render: (h, params) => {
                let type = params.row.state === 0 ? 'success' : 'danger'
                let title = params.row.state === 0 ? '已启用' : '已禁用'
                return <el-tag type={type}>{title}</el-tag>
              }
            },
            {
              prop: 'state',
              label: '操作',
              width: 200,
              render: (h, params) => {
                let type = params.row.state === 0 ? 'success' : 'danger'
                let title = params.row.state === 0 ? '启用' : '禁用'
                return (<div>
                    <el-button type="success" size="mini" plain icon="el-icon-edit-outline" nativeOnClick={() => {
                        this.handleEdit(params)
                    }}>修改</el-button>
                    <el-button size="mini" plain type={type} nativeOnClick={() => {
                        this.handleDisEnable(params, state)
                    }}>{title}</el-button>
                  </div>
                )
              }
            },
          ], // 需要展示的列
          pagination: {
            show: true,
            total: 0,
            pageNum: 1,
            pageSize: 15
          }, // 分页参数
          options: {
            index: false, //序号
            mutiSelect: true, //序号
            initTable: true, // 是否一进来就加载表格数据
          }, // table 的参数

          formInline: {
            user: '',
            region: ''
          }
        }
      },
      methods: {
        //   查询列表
        getList() {
          let param = {
              pageIndex: this.pagination.pageNum,
              pageSize: this.pagination.pageSize
          }
          this.options.loading = true
          IndexService.getList(param)
            .then(res => {
              if(res.success) {
                  this.pagination.total = res.total
                  this.list = res.rows
              }
            }).finally(() => {
              this.options.loading = false
            })
        },
        // 新增
        handleAdd() {
          this.$router.push('/daily-mange/my-brand-handle')
        },

        // 查询
        search() {
            this.pagination.pageNum = 1;
            this.pagination.total = 0;
            this.getList()
        },

        // 编辑
        handleEdit(row, index) {
            this.$router.push({
                path:'/daily-mange/my-brand-handle',
                param:{
                    id: row.field1
                }
            })
        },

        //  启用 / 禁用
        handleDisEnable(params, state) {
        },

        //  删除
        handleDel() {
        },

        handleSelectionChange(rows) {
            console.log(rows)
        },
        
        //查看资质图片
        check(params) {
            //   this.$message(`click call ${params.row.date}`)
            this.$alert('<img style="width: 100%;" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550569527394&di=499bf315a80c859a4acf70e24e766221&imgtype=jpg&src=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D843574905%2C2376842750%26fm%3D214%26gp%3D0.jpg">', {
                dangerouslyUseHTMLString: true
              });
        }
      }
    }